package com.pig4cloud.mall.product.dto;

import com.pig4cloud.mall.product.entity.Category;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @author fangyu
 * @version v1.0.0
 * @date 2020/11/25 3:22 下午
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CategoryTree extends TreeNode implements Serializable {
	/**
	 * 分类名称
	 */
	private String name;
	/**
	 * 层级
	 */
	private Integer level;
	/**
	 * 是否显示[0-不显示，1显示]
	 */
	private Integer showStatus;
	/**
	 * 排序
	 */
	private Integer sort;
	/**
	 * 图标地址
	 */
	private String icon;
	/**
	 * 计量单位
	 */
	private String productUnit;
	/**
	 * 商品数量
	 */
	private Integer productCount;

	public CategoryTree() {
	}
	public CategoryTree(Category category) {
		super.catId = Math.toIntExact(category.getCatId());
		super.parentCid = Math.toIntExact(category.getParentCid());
		this.name = category.getName();
		this.level = category.getCatLevel();
		this.showStatus = category.getShowStatus();
		this.sort = category.getSort();
		this.icon = category.getIcon();
		this.productUnit = category.getProductUnit();
		this.productCount = category.getProductCount();
	}
}
